<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>城市页面</title>

    <!-- Bootstrap -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
    <!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
    <script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>
    <!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
</head>
<body>
<center>
    <h1>城市分布页面</h1>
    <table class="table table-bordered">
        <thead>
        <tr>
            <th>城市编号</th>
            <th>城市名</th>
            <th>人口</th>
            <th>国家名</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
            <tr th:each="citys,cityStat : ${city.list}">
                <td th:text="${citys.cityId}"></td>
                <td th:text="${citys.cityName}"></td>
                <td th:text="${citys.citySize}"></td>
                <!--<td th:text="${citys.getCountry().cname}"></td>-->
                <td>
                    <button type="button" class="btn btn-success" onclick="ad()">添加</button>
                    <button type="button" class="btn btn-danger" th:onclick="del([[${citys.cityId}]])">删除</button>
                    <button type="button" class="btn btn-danger" th:onclick="chance([[${citys.cityId}]])">修改</button>
                </td>
            </tr>
        </tbody>
        <tfoot>
            <tr>
                <td>
                    <a href="/city/page/1/3">首页</a>
                    <a th:href="@{'/city/page/'+${city.pageNum-1}+'/3'}">上一页</a>
                    <a th:href="@{'/city/page/'+${city.pageNum+1}+'/3'}">下一页</a>
                    <a th:href="@{'/city/page/'+${city.total}+'/3'}">尾页</a>
                </td>
            </tr>
        </tfoot>
</center>
<script>
    function chance(cityId) {
        location.href = 'one/' + cityId;
    }

    function del(cityId) {
        /*$.ajax({
            method : 'delete',
            url : 'delete/' + cityId
            })*/
        location.href = 'delete/' + cityId;
    }

    function ad() {
        location.href = '/toInsert.html';
    }

</script>
</body>
</html>